package github.kawaiior.yuanchuxiuzhen.core.init.event;

import github.kawaiior.yuanchuxiuzhen.common.entity.addon.render.*;
import github.kawaiior.yuanchuxiuzhen.common.entity.render.CoffinGuardEntityRender;
import github.kawaiior.yuanchuxiuzhen.common.entity.render.SoulIronBeastRender;
import github.kawaiior.yuanchuxiuzhen.common.entity.render.SoulWanderingRender;
import github.kawaiior.yuanchuxiuzhen.core.init.BlockInit;
import github.kawaiior.yuanchuxiuzhen.core.init.EntityInit;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD,value = Dist.CLIENT)
public class ClientEvent {

    private static void initFireBlockRender(){
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_1.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_2.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_3.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_4.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_5.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_6.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_7.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_8.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YANG_FIRE_9.get(), RenderType.getCutout());

        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_1.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_2.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_3.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_4.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_5.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_6.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_7.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_8.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockInit.YIN_FIRE_9.get(), RenderType.getCutout());
    }

    @SubscribeEvent
    public static void onClientSetupEvent(FMLClientSetupEvent event){
        event.enqueueWork(()->{
            initFireBlockRender();

            Minecraft mc = Minecraft.getInstance();
            EntityRendererManager manager = mc.getRenderManager();

//            manager.register(EntityInit.EXAMPLE_ENTITY.get(),new ExampleEntityRender(manager));

            manager.register(EntityInit.COFFIN_GUARD.get(), new CoffinGuardEntityRender(manager));
            manager.register(EntityInit.SOUL_IRON_BEAST.get(), new SoulIronBeastRender(manager));
            manager.register(EntityInit.SOUL_WANDERING_ENTITY.get(), new SoulWanderingRender(manager));

            // 拓展
            manager.register(EntityInit.RAIN_FROG_ENTITY.get(), new RainFrogEntityRender(manager));
            manager.register(EntityInit.HOST_CRAB_ENTITY.get(), new HostCrabEntityRender(manager));
            manager.register(EntityInit.PU_BIRD_ENTITY.get(), new PuBirdEntityRender(manager));
            manager.register(EntityInit.EAGLE_OWL_ENTITY.get(), new EagleOwlEntityRender(manager));
            manager.register(EntityInit.ARMY_ANT_ENTITY.get(), new ArmyAntEntityRender(manager));
            manager.register(EntityInit.STONE_GIANT_ENTITY.get(), new StoneGiantEntityRender(manager));
            manager.register(EntityInit.BONE_WOLF_ENTITY.get(), new BoneWolfEntityRender(manager));
            manager.register(EntityInit.THUNDER_DEER_ENTITY.get(), new ThunderDeerEntityRender(manager));
            manager.register(EntityInit.STONE_CAMEL_ENTITY.get(), new StoneCamelEntityRender(manager));
            manager.register(EntityInit.BEAST_KING_ENTITY.get(), new BeastKingEntityRender(manager));
            manager.register(EntityInit.THUNDER_FIELD_CROCODILE_ENTITY.get(), new ThunderFieldCrocodileEntityRender(manager));
            manager.register(EntityInit.KIRIN_ENTITY.get(), new KirinEntityRender(manager));
            manager.register(EntityInit.WHITE_POND_ENTITY.get(), new WhitePondEntityRender(manager));
            manager.register(EntityInit.FIRE_FOX_ENTITY.get(), new FireFoxEntityRender(manager));
        });
    }


}
